package server;

import java.io.*;
import java.net.*;

public class mainServerSocket {
	
	public static void main(String [] args) throws IOException{
	
	int port=2000;
	
	//ServerSocket in ascolto
	ServerSocket serverSocket=new ServerSocket(port);
	//Aspetto la connessione di un client e poi restituisco un socket
	Socket socket=serverSocket.accept();
	System.out.println("Socket creato"+socket.getInetAddress()+" "+socket.getLocalPort());
	
	//Ottengo gli Stream Handler
    BufferedReader input=new BufferedReader(new InputStreamReader(socket.getInputStream()));
	BufferedWriter output=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
	
	while(true){
		String message=input.readLine();
		if(message.equalsIgnoreCase("tua mamma")){
			message="Piscia in piedi";
		}
		output.write(message);
		output.newLine();
		output.flush();
		
		
		
		
	}
	
	
	}



}
